home *** CD-ROM | disk | FTP | other *** search
- /*
- This is a simple implementation of execl() for MS-DOS 2.0/CI-C86 v2.04B. See
- comments for details. If someone knows details about what exactly FCB1 and
- FCB2 are used for, I would be interested in knowing. Would they serve any
- purpose with DOS 2.0 calls? Are they stdin/stdout? Thanks, and have fun!
-
- The file format is CI's ARCHive format. If you don't have that, '-ARCHIVE-'
- starts lines separating files. Just split them there with an editor (and get
- rid of the line). The file name and size is also on the separator line.
-
- Questions, comments, flames, vegetables, etc. can be sent to Alan Batie via:
-
-
- >>----->>-------------( Nathan C. Myers )-----------------\
- / |
- | ...!decvax!tektronix!ogcvax!hp-pcd!orstcs!nathan |
- | nathan.oregon-state@RAND-RELAY |
- \___________________________________________________/
-
-
- --------------------------------Tear off here---------------------------------
- -ARCHIVE- exec.c 1395
- /*
- * File name: exec.c
- *
- * Belongs to: System utilities
- * Description: Executes a program specified on command line. Mostly
- * used as demonstation of execl() function call.
- *
- * Version: 0.0
- * History: None
- * Last change: 3/3/84 - Original code. Alan Batie
- *
- * Nathan C. Myers:
- * UUCP: ...!decvax!tektronix!orstcs!nathan
- * ARPANET: nathan.oregon-state@RAND-RELAY
- */
-
- /* SET RUN TIME DEFAULT VALUES
- */
-
- int _MAXFMEM=0x200; /* MAXIMUM STACK+HEAP REQUIRED */
- int _MINFMEM=0x50; /* MINIMUM STACK+HEAP REQUIRED */
- int _MINRMEM=0; /* RESERVED FOR COMMAND.COM AT TOP OF MEM */
- /* Not necessary, as memory limit set low */
- int _STAKMEM=64; /* MIN STACK IN SBRK BEFORE REFUSING ALLOC */
-
- #include "stdio.h"
-
- /*
- * This program can only be compiled under big model, although small could
- * be used if execl() set up for small model. Other bugs: CI-C86 doesn't
- * recognize quoted strings in the command l)w$ processor. Will fix this
- * Real Soon Now.
- */
-
- /* exec <prog> [ <command line> ] */
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- int err;
-
- if (argc == 1)
- {
- fputs("exec: usage exec <prog> [ <com. line> ]\n", stderr);
- exit(255);
- }
-
- if (argc >= 3)
- {
- err = execl(argv[1], argv[2]);
- }
- else
- {
- err = execl(argv[1], " ");
- }
-
- if (err != 0)
- {
- sys_err(err);
- }
- }
- -ARCHIVE- execl.c 1523
- /*
- * File name: execl.c
- *
- * Belongs to: System extended library
- * Description: Executes another program as though a subroutine.
- *
- * Version: 0.0
- * History: None
- * Last change: 3/3/84 - Original code. Alan Batie
- *
- * Nathan C. Myers:
- * UUCP: ...!decvax!tektronix!orstcs!nathan
- * ARPANET: nathan.oregon-state@RAND-RELAY
- */
-
- /* This program can only be compiled under big model, small could be used
- * if pointers passed to exec() were built for large model - see CI docs.
- * The _default.c vars must be set by the program, so enough space is
- * available for new program. Requires CI-C86 2.04B or better. Previous
- * versions did not fully correct MS-DOS 2.0 bugs, and don't work. (Not
- * sure when it started working - 2.03x *might* work.) Other brands will
- * work if they have a correct (with bug spray) call to function 4B.
- */
-
- #include "stdio.h"
-
- execl(path, arg_str)
- char *path;
- char *arg_str;
- {
- struct parm_struct
- {
- int env_str_seg;
- char *com_line;
- char *fcb1;
- char *fcb2;
- } parm_block;
-
- int err;
-
- /* Initialize parameter block */
-
- parm_block.env_str_seg =
- parm_block.fcb1 =
- parm_block.fcb2 = NULL;
-
- /* Change format of string to [count][string] */
-
- parm_block.com_line = alloc(strlen(arg_str) + 2);
- *parm_block.com_line = strlen(arg_str);
- strcpy(parm_block.com_line + 1, arg_str);
-
- /* Go do it! (last parm = 0 means load and execute, 3 = just load) */
-
- err = loadexec(path, &parm_block, 0);
- }
- -ARCHIVE- sys_err.c 1880
- /*
- * File name: sys_err.c
- *
- * Belongs to: System library
- * Description: Displays error message based on error code returned
- * from system call.
- *
- * Version: 1.0
- * Last change: None - original code
- * Author: Alan Batie
- */
-
- #include "stdio.h"
- #include "stdext.h"
-
- sys_err(err_code)
- int err_code;
- {
- char buf[10];
-
- switch (err_code)
- {
- case 1:
- fputs("\nInvalid function number\n", STDERR);
- break;
-
- case 2:
- fputs("\nFile not found\n", STDERR);
- break;
-
- case 3:
- fputs("\nPath not found\n", STDERR);
- break;
-
- case 4:
- fputs("\nToo many open files\n", STDERR);
- break;
-
- case 5:
- fputs("\nAccess denied\n", STDERR);
- break;
-
- case 6:
- fputs("\nInvalid handle\n", STDERR);
- break;
-
- case 7:
- fputs("\nMemory control blocks destroyed\n", STDERR);
- break;
-
- case 8:
- fputs("\nInsufficient memory\n", STDERR);
- break;
-
- )0!case 9:
- fputs("\nInvalid memory block address\n", STDERR);
- break;
-
- case 10:
- fputs("\nInvalid environment\n", STDERR);
- break;
-
- case 11:
- fputs("\nInvalid format\n", STDERR);
- break;
-
- case 12:
- fputs("\nInvalid access code\n", STDERR);
- break;
-
- case 13:
- fputs("\nInvalid data\n", STDERR);
- break;
-
- case 14:
- fputs("\nUnknown error code ", STDERR);
- itoa(err_code, buf);
- fputs(buf, STDERR);
- fpu:>2e", STDERR);
- break;
-
- case 15:
- fputs("\nInvalid drive was specified\n", STDERR);
- break;
-
- case 16:
- fputs("\nAttempted to remove current directory\n", STDERR)
- break;
-
- case 17:
- fputs("\nNot same device\n", STDERR);
- break;
-
- case 18:
- fputs("\nNo more files\n", STDERR);
- break;
-
- default:
- fputs("\nUnknown error code ", STDERR);
- itoa(err_code, buf);
- fputs(buf, STDERR);
- fputs("\n", STDERR);
- break;
- }
- }
- */
-